<?php
// Tikrinam su ajax registracijoje ivedamus duomenis.
// Speju cia gali buti saugumo spraga.
// Nebaigta funkcija su Kodo ivedimu ziurint i paveiskliuka.
if (isset($_GET) && !empty($_GET)) {
	include_once("priedai/conf.php");

	if (isset($_GET['nick']) && !empty($_GET['nick'])) {
		if (preg_match('/[^A-Za-z0-9]/', $_GET['nick'])) {
			$error = "<img src=\"images/icons/cross.png\" alt=\"X\" align=\"absmiddle\" /> Naudok tik raides ir skaičius";
			echo $error;
		}
		else {
			$vardas = htmlentities($_GET['nick'], ENT_QUOTES);
			if (isset($vardas)) {
				$einfo = mysql_num_rows(mysql_query("SELECT `nick` FROM `".LENTELES_PRIESAGA."users` WHERE `nick`=".escape($vardas)." LIMIT 1"));
				if ($einfo != 0 ) { $error = "<img src=\"images/icons/cross.png\" alt=\"X\" align=\"absmiddle\" />"; }
				else { $error = "<img src=\"images/icons/tick.png\" alt=\"√\" align=\"absmiddle\" />"; }
				echo $error;
			}
		}
	}
	if (isset($_GET['email']) && !empty($_GET['email'])) {
		$email = htmlentities($_GET['email'], ENT_QUOTES);
		if (isset($email)) {
			$einfo = mysql_num_rows(mysql_query("SELECT `email` FROM `".LENTELES_PRIESAGA."users` WHERE `email`=".escape($email)." LIMIT 1"));
			if ($einfo != 0 ) { $error = "<img src=\"images/icons/cross.png\" alt=\"X\" align=\"absmiddle\" />"; }
			else { $error = "<img src=\"images/icons/tick.png\" alt=\"√\" align=\"absmiddle\" />"; }
		}
		echo $error;
	}
	if (isset($_GET['kode']) && !empty($_GET['kode'])) {
		if (preg_match('/[^A-Za-z0-9]/', $_GET['nick'])) {
			$error = "<img src=\"images/icons/cross.png\" alt=\"X\" align=\"absmiddle\" /> Naudok tik raides ir skaičius";
		}
		else {
			$kode = strtoupper(htmlentities($_GET['c'], ENT_QUOTES));
			if (isset($_SESSION['code']) && !empty($_SESSION['code'])) {
				if ($kode != $_SESSION['kode']) { $error = "<img src=\"images/icons/cross.png\" alt=\"X\" align=\"absmiddle\" />"; }
				else { $error = "<img src=\"images/icons/tick.png\" alt=\"√\" align=\"absmiddle\" />"; }
			}
		}
		echo $error;
	}
}
?>